import Vue from "vue";
import VueRouter from "vue-router";
import Index from "../views/Index.vue";
import Login from "../components/Login.vue";
import Logon from "../components/Logon.vue";
import Error from "../components/Error.vue";
Vue.use(VueRouter);

const routes = [
  {
    path: "/login",
    name: "login",
    component: Login
  },
  {
    path: "/logon",
    name: "logon",
    component: Logon
  },
  {
    path: "",
    name: "index",
    component: Index,
    children: [
      {
        path: "/",
        component: () => import("../components/Home.vue")
      },
      {
        path: "/home",
        component: () => import("../components/Home.vue")
      },
      {
        path: "/home2",
        component: () => import("../components/Home2.vue")
      },
      {
        path: "/home3",
        component: () => import("../components/Home3.vue")
      },
      {
        path: "/home4",
        component: () => import("../components/Home4.vue")
      },
      {
        path: "/article",
        component: () => import("../components/article.vue")
      },
      {
        path: "/articleList",
        component: () => import("../components/articleList.vue")
      },
      {
        path: "/editArticle",
        component: () => import("../components/editArticle.vue")
      },
      {
        path: "/user",
        component: () => import("../components/user.vue")
      },
      {
        path: "/shareList",
        component: () => import("../components/shareList.vue")
      },
      {
        path: "/attentionList",
        component: () => import("../components/attentionList.vue")
      },
      {
        path: "/imgList",
        component: () => import("../components/imgList.vue")
      },
      {
        path: "/commodityList",
        component: () => import("../components/commodityList.vue")
      },
      {
        path: "/commodity",
        component: () => import("../components/commodity.vue")
      },
      {
        path: "/editCommodity",
        component: () => import("../components/editCommodity.vue")
      },
    ]
  },
  {
    path: "*",
    name: "error",
    component: Error
  }
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes
});

export default router;
